//
//  StrategyNearbyPhotoCollectionViewCell.m
//  ITrip
//
//  Created by dllo on 15/6/1.
//  Copyright (c) 2015年 lanou3g.com 蓝鸥科技. All rights reserved.
//

#import "StrategyNearbyPhotoCollectionViewCell.h"

@implementation StrategyNearbyPhotoCollectionViewCell

- (void)dealloc
{
    [self.photo_imageview release];
    [super dealloc];
}

- (void)setPhotomodel:(StrategyNearbyPhotoModel *)photomodel
{
//    static NSInteger num = 0;
//    static CGFloat height1 = 0;
//    static CGFloat height2 = 0;
//    static CGFloat lastHeight1 = 0;
//    static CGFloat lastHeight2 = 0;
//    CGRect frame = [UIScreen mainScreen].bounds;
//    CGFloat height = frame.size.width / 2 * (photomodel.photo_image_height / (CGFloat)photomodel.photo_image_width);
//    
//    if (number % 2 == 0) {
//        if (num <= number) {
//            num = number;
//            self.frame = CGRectMake(0, height1 += height, frame.size.width / 2, height);
//            lastHeight1 = height;
//        } else {
//            num = number;
//            self.frame = CGRectMake(0, height1 -= lastHeight1, frame.size.width / 2, height);
//            lastHeight1 = height;
//        }
//        
//    } else {
//        if (num <= number) {
//            num = number;
//            self.frame = CGRectMake(frame.size.width / 2, height2 += height, frame.size.width / 2, height);
//             NSLog(@"%f", lastHeight2);
//            lastHeight2 = height;
//        } else {
//            num = number;
//            self.frame = CGRectMake(frame.size.width / 2, height2 -= lastHeight2, frame.size.width / 2, height);
//            lastHeight2 = height;
//        }
//        
//        
//    }
    
    [self.photo_imageview setImageWithURL:[NSURL URLWithString:photomodel.photo_image_url] placeholderImage:[UIImage imageNamed:@"defaultPicture"]];
    if (photomodel.photo_image_url != nil && ![photomodel.photo_image_url isEqual:[NSNull null]]) {
        self.height = self.frame.size.width * (photomodel.photo_image_height / (CGFloat)photomodel.photo_image_width);
        
        self.photo_imageview.frame = CGRectMake(0, 0, self.frame.size.width, self.height);
        
        self.photo_imageview.backgroundColor = [UIColor whiteColor];
    }
}

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self createMyView];
    }
    return self;
}

- (void)createMyView
{
    self.photo_imageview = [[UIImageView alloc]init];
    [self.contentView addSubview:self.photo_imageview];
    
    [self.photo_imageview release];
}



@end
